// router.js
import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/pages/Home'

Vue.use(Router)

export function createRouter () {
  return new Router({
    mode: 'history', //不能使用hash ，服务端不支持
    routes: [
        {
            path: '/',
            name: 'home',
            component: Home
          },
        {
          path: '/about',
          name: 'about',
          component: () => import('./src/pages/About')
        },
        {
          path: '/posts',
          name: 'post-list',
          component: () => import('./src/pages/posts')
        },
        {
          path: '*',
          name: 'error404',
          component: () => import('./src/pages/404')
        }
      ]
  })
}